package com.lancoo.evaluate.util;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Environment;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class Util {
    public static void cache(String result) {
        String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "result.txt";
        File file = new File(path);
        try {
            FileWriter fileWriter = new FileWriter(file, true);
            fileWriter.write("\r\n\r\n\r\n");
            fileWriter.write(result);
            fileWriter.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void openAppSetting(Activity activity) {
        Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        Uri uri = Uri.fromParts("package", activity.getPackageName(), null);
        intent.setData(uri);
        activity.startActivity(intent);
    }
}
